<?
/*
Bitsand - a web-based booking system for LRP events
Copyright (C) 2006, 2007 Russell Peter Phillips

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

include ('inc_head_db.php');
include ('inc_admin.php');
include ('inc_head_html.php');

//Report on number of spell cards & lore sheets required for booked characters

//Get list of players
$key = CRYPT_KEY;
$sql = "SELECT bkPlayerID, bkDatePaymentConfirmed, stPlayerID, stSkillID, stPoints " .
	"FROM skillstaken, bookings " .
	"WHERE stPlayerID = bkPlayerID AND bkDatePaymentConfirmed <> '0000-00-00'";
$result = mysqli_query ($link, $sql);

//Initialise counters
$iHealing = 0;
$iIncant1 = 0;
$iIncant2 = 0;
$iSpell1 = 0;
$iSpell2 = 0;
$iSenseMagic = 0;
$iEvaluate = 0;
$iPotionLore = 0;
$iPoisonLore = 0;
$iRecForgery = 0;

while ($row = mysqli_fetch_assoc ($result)) {
	if ($row ['stSkillID'] == 10) {
		//At least 10 cards
		$iHealing += 10;
		//1 card for every point spent over 7
		if ($row ['stPoints'] > 7)
			$iHealing += $row ['stPoints'] - 7;
	}
	if ($row ['stSkillID'] == 2)
		$iSpell1 += 4;
	if ($row ['stSkillID'] == 4) {
		$iSpell1 += 5;
		$iSpell2 += 4;
	}
	if ($row ['stSkillID'] == 6)
		$iIncant1 += 4;
	if ($row ['stSkillID'] == 8) {
		$iIncant1 += 5;
		$iIncant2 += 4;
	}
	if ($row ['stSkillID'] == 14)
		$iSenseMagic++;
	if ($row ['stSkillID'] == 16)
		$iEvaluate++;
	if ($row ['stSkillID'] == 18)
		$iPotionLore++;
	if ($row ['stSkillID'] == 20)
		$iPoisonLore++;
	if ($row ['stSkillID'] == 22)
		$iRecForgery++;
}
?>

<h1><?=TITLE?> - Cards &amp; Lore Sheets</h1>

<p>
<a href = 'admin.php'>Admin</a>
</p>

<p>
Number of cards & lore sheets needed for the pre-booked characters:
</p>

<p>
<?=$iHealing?> Healing cards per day
</p>

<p>
<?=$iIncant1?> Incantation 1 cards per day<br>
<?=$iIncant2?> Incantation 2 cards per day<br>
</p>

<p>
<?=$iSpell1?> Spell 1 cards per day<br>
<?=$iSpell2?> Spell 2 cards per day<br>
</p>

<p>
<?=$iSenseMagic?> Sense Magic lore sheets<br>
<?=$iEvaluate?> Evaluate lore sheets<br>
<?=$iPotionLore?> Potion Lore lore sheets<br>
<?=$iPoisonLore?> Poison Lore lore sheets<br>
<?=$iRecForgery?> Recognise Forgery lore sheets<br>
</p>

<?
include ('inc_foot.php');
?>
